﻿using Advantech.MotionComponent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionCore
{
    public class AlarmHelper
    {
        public bool PowerOFF { get; set; } = false;
        public bool Door1_Open { get; set; } = false;
        public bool Door2_Open { get; set; } = false;
        public bool Door3_Open { get; set; } = false;
        public bool Door4_Open { get; set; } = false;
        public bool Door5_Open { get; set; } = false;
        public bool Door5_NotRest { get; set; } = false;
        public bool EMO1_Error { get; set; } = false;
        public bool EMO2_Error { get; set; } = false;
        public bool CDAError { get; set; } = false;
        public bool VACError { get; set; } = false;
        public bool EfemCDAError { get; set; } = false;
        public bool EfemVACError { get; set; } = false;

        public bool CV1_Y_LMT_P { get; set; } = false;
        public bool CV1_Y_LMT_N { get; set; } = false;
        public bool CV1_Y_IsHomeAlready { get; set; } = false;
        public bool CV1_Y_Alarm { get; set; } = false;
        public bool CV1_Y_ErrorStop { get; set; } = false;

        public bool CV1_TrackSW_Y_LMT_P { get; set; } = false;
        public bool CV1_TrackSW_Y_LMT_N { get; set; } = false;
        public bool CV1_TrackSW_Y_IsHomeAlready { get; set; } = false;
        public bool CV1_TrackSW_Y_Alarm { get; set; } = false;
        public bool CV1_TrackSW_Y_ErrorStop { get; set; } = false;


        public bool CV2_Y_LMT_P { get; set; } = false;
        public bool CV2_Y_LMT_N { get; set; } = false;
        public bool CV2_Y_IsHomeAlready { get; set; } = false;
        public bool CV2_Y_Alarm { get; set; } = false;
        public bool CV2_Y_ErrorStop { get; set; } = false;

        public bool CV2_TrackSW_Y_LMT_P { get; set; } = false;
        public bool CV2_TrackSW_Y_LMT_N { get; set; } = false;
        public bool CV2_TrackSW_Y_IsHomeAlready { get; set; } = false;
        public bool CV2_TrackSW_Y_Alarm { get; set; } = false;
        public bool CV2_TrackSW_Y_ErrorStop { get; set; } = false;

        public bool CCD1_X_LMT_P { get; set; } = false;
        public bool CCD1_X_LMT_N { get; set; } = false;
        public bool CCD1_X_IsHomeAlready { get; set; } = false;
        public bool CCD1_X_Alarm { get; set; } = false;
        public bool CCD1_X_ErrorStop { get; set; } = false;

        public bool CCD1_Y_LMT_P { get; set; } = false;
        public bool CCD1_Y_LMT_N { get; set; } = false;
        public bool CCD1_Y_IsHomeAlready { get; set; } = false;
        public bool CCD1_Y_Alarm { get; set; } = false;
        public bool CCD1_Y_ErrorStop { get; set; } = false;

        public bool CCD1_Z_LMT_P { get; set; } = false;
        public bool CCD1_Z_LMT_N { get; set; } = false;
        public bool CCD1_Z_IsHomeAlready { get; set; } = false;
        public bool CCD1_Z_Alarm { get; set; } = false;
        public bool CCD1_Z_ErrorStop { get; set; } = false;

        public bool CCD2_X_LMT_P { get; set; } = false;
        public bool CCD2_X_LMT_N { get; set; } = false;
        public bool CCD2_X_IsHomeAlready { get; set; } = false;
        public bool CCD2_X_Alarm { get; set; } = false;
        public bool CCD2_X_ErrorStop { get; set; } = false;

        public bool CCD2_Y_LMT_P { get; set; } = false;
        public bool CCD2_Y_LMT_N { get; set; } = false;
        public bool CCD2_Y_IsHomeAlready { get; set; } = false;
        public bool CCD2_Y_Alarm { get; set; } = false;
        public bool CCD2_Y_ErrorStop { get; set; } = false;

        public bool CCD2_Z_LMT_P { get; set; } = false;
        public bool CCD2_Z_LMT_N { get; set; } = false;
        public bool CCD2_Z_IsHomeAlready { get; set; } = false;
        public bool CCD2_Z_Alarm { get; set; } = false;
        public bool CCD2_Z_ErrorStop { get; set; } = false;

        public bool Insp1_Y_LMT_P { get; set; } = false;
        public bool Insp1_Y_LMT_N { get; set; } = false;
        public bool Insp1_Y_IsHomeAlready { get; set; } = false;
        public bool Insp1_Y_Alarm { get; set; } = false;
        public bool Insp1_Y_ErrorStop { get; set; } = false;

        public bool Insp1_RM_Z_LMT_P { get; set; } = false;
        public bool Insp1_RM_Z_LMT_N { get; set; } = false;
        public bool Insp1_RM_Z_IsHomeAlready { get; set; } = false;
        public bool Insp1_RM_Z_Alarm { get; set; } = false;
        public bool Insp1_RM_Z_ErrorStop { get; set; } = false;

        public bool Insp2_Y_LMT_P { get; set; } = false;
        public bool Insp2_Y_LMT_N { get; set; } = false;
        public bool Insp2_Y_IsHomeAlready { get; set; } = false;
        public bool Insp2_Y_Alarm { get; set; } = false;        
        public bool Insp2_Y_ErrorStop { get; set; } = false;
        public bool Insp2_RM_Z_LMT_P { get; set; } = false;
        public bool Insp2_RM_Z_LMT_N { get; set; } = false;
        public bool Insp2_RM_Z_IsHomeAlready { get; set; } = false;
        public bool Insp2_RM_Z_Alarm { get; set; } = false;
        public bool Insp2_RM_Z_ErrorStop { get; set; } = false;

        public bool Insp3_Y_LMT_P { get; set; } = false;
        public bool Insp3_Y_LMT_N { get; set; } = false;
        public bool Insp3_Y_IsHomeAlready { get; set; } = false;
        public bool Insp3_Y_Alarm { get; set; } = false;
        public bool Insp3_Y_ErrorStop { get; set; } = false;

        public bool Insp3_RM_Z_LMT_P { get; set; } = false;
        public bool Insp3_RM_Z_LMT_N { get; set; } = false;
        public bool Insp3_RM_Z_IsHomeAlready { get; set; } = false;
        public bool Insp3_RM_Z_Alarm { get; set; } = false;
        public bool Insp3_RM_Z_ErrorStop { get; set; } = false;

        public bool Insp4_Y_LMT_P { get; set; } = false;
        public bool Insp4_Y_LMT_N { get; set; } = false;
        public bool Insp4_Y_IsHomeAlready { get; set; } = false;
        public bool Insp4_Y_Alarm { get; set; } = false;
        public bool Insp4_Y_ErrorStop { get; set; } = false;

        public bool Insp4_RM_Z_LMT_P { get; set; } = false;
        public bool Insp4_RM_Z_LMT_N { get; set; } = false;
        public bool Insp4_RM_Z_IsHomeAlready { get; set; } = false;
        public bool Insp4_RM_Z_Alarm { get; set; } = false;
        public bool Insp4_RM_Z_ErrorStop { get; set; } = false;

        public bool Enter_CV1_ErrorStop { get; set; } = false; 
        public bool Enter_CV2_ErrorStop { get; set; } = false;
        public bool Insp1_CV1_ErrorStop { get; set; } = false;
        public bool Insp1_CV2_ErrorStop { get; set; } = false;
        public bool Insp2_CV1_ErrorStop { get; set; } = false;
        public bool Insp2_CV2_ErrorStop { get; set; } = false;
        public bool Insp3_CV1_ErrorStop { get; set; } = false;
        public bool Insp3_CV2_ErrorStop { get; set; } = false;
        public bool Insp4_CV1_ErrorStop { get; set; } = false;
        public bool Insp4_CV2_ErrorStop { get; set; } = false;


        public void AlarmReset()
        {


            PowerOFF = false;
            Door1_Open = false;
            Door2_Open =false;
            Door3_Open =false;
            Door4_Open =false;
            Door5_Open = false;
            Door5_NotRest = false;

            EMO1_Error = false;
            EMO2_Error = false;
            
            CDAError = false;
            VACError = false;
            EfemCDAError = false;
            EfemVACError = false;

            CV1_Y_LMT_P =false;
            CV1_Y_LMT_N =false;
            CV1_Y_IsHomeAlready = false;
            CV1_Y_Alarm = false;
            CV1_Y_ErrorStop = false;

            CV2_Y_LMT_P = false;
            CV2_Y_LMT_N = false;
            CV2_Y_IsHomeAlready = false;
            CV2_Y_Alarm = false;
            CV2_Y_ErrorStop = false;

            CV1_TrackSW_Y_LMT_P = false;
            CV1_TrackSW_Y_LMT_N = false;
            CV1_TrackSW_Y_IsHomeAlready = false;
            CV1_TrackSW_Y_Alarm = false;
            CV1_TrackSW_Y_ErrorStop = false;

            CV2_TrackSW_Y_LMT_P = false;
            CV2_TrackSW_Y_LMT_N = false;
            CV2_TrackSW_Y_IsHomeAlready = false;
            CV2_TrackSW_Y_Alarm = false;
            CV2_TrackSW_Y_ErrorStop = false;

            CCD1_X_LMT_P = false;
            CCD1_X_LMT_N = false;
            CCD1_X_IsHomeAlready = false;
            CCD1_X_Alarm = false;
            CCD1_X_ErrorStop = false;
            CCD1_Y_LMT_P = false;
            CCD1_Y_LMT_N = false;
            CCD1_Y_IsHomeAlready = false;
            CCD1_Y_Alarm = false;
            CCD1_Y_ErrorStop = false;
            CCD1_Z_LMT_P = false;
            CCD1_Z_LMT_N = false;
            CCD1_Z_IsHomeAlready = false;
            CCD1_Z_Alarm = false;
            CCD1_Z_ErrorStop = false;

            CCD2_X_LMT_P = false;
            CCD2_X_LMT_N = false;
            CCD2_X_IsHomeAlready = false;
            CCD2_X_Alarm = false;
            CCD2_X_ErrorStop = false;
            CCD2_Y_LMT_P = false;
            CCD2_Y_LMT_N = false;
            CCD2_Y_IsHomeAlready = false;
            CCD2_Y_Alarm = false;
            CCD2_Y_ErrorStop = false;
            CCD2_Z_LMT_P = false;
            CCD2_Z_LMT_N = false;
            CCD2_Z_IsHomeAlready = false;
            CCD2_Z_Alarm = false;
            CCD2_Z_ErrorStop = false;

            Insp1_Y_LMT_P = false;
            Insp1_Y_LMT_N = false;
            Insp1_Y_IsHomeAlready = false;
            Insp1_Y_Alarm = false;
            Insp1_Y_ErrorStop = false;
            Insp1_RM_Z_LMT_P = false;
            Insp1_RM_Z_LMT_N = false;
            Insp1_RM_Z_IsHomeAlready = false;
            Insp1_RM_Z_Alarm = false;
            Insp1_RM_Z_ErrorStop = false;

            Insp2_Y_LMT_P = false;
            Insp2_Y_LMT_N = false;
            Insp2_Y_IsHomeAlready = false;
            Insp2_Y_Alarm = false;
            Insp2_Y_ErrorStop = false;
            Insp2_RM_Z_LMT_P = false;
            Insp2_RM_Z_LMT_N = false;
            Insp2_RM_Z_IsHomeAlready = false;
            Insp2_RM_Z_Alarm = false;
            Insp2_RM_Z_ErrorStop = false;

            Insp3_Y_LMT_P = false;
            Insp3_Y_LMT_N = false;
            Insp3_Y_IsHomeAlready = false;
            Insp3_Y_Alarm = false;
            Insp3_Y_ErrorStop = false;
            Insp3_RM_Z_LMT_P = false;
            Insp3_RM_Z_LMT_N = false;
            Insp3_RM_Z_IsHomeAlready = false;
            Insp3_RM_Z_Alarm = false;
            Insp3_RM_Z_ErrorStop = false;

            Insp4_Y_LMT_P = false;
            Insp4_Y_LMT_N = false;
            Insp4_Y_IsHomeAlready = false;
            Insp4_Y_Alarm = false;
            Insp4_Y_ErrorStop = false;
            Insp4_RM_Z_LMT_P = false;
            Insp4_RM_Z_LMT_N = false;
            Insp4_RM_Z_IsHomeAlready = false;
            Insp4_RM_Z_Alarm = false;
            Insp4_RM_Z_ErrorStop = false;

            Enter_CV1_ErrorStop = false;
            Enter_CV2_ErrorStop = false;
            Insp1_CV1_ErrorStop = false;
            Insp1_CV2_ErrorStop = false;
            Insp2_CV1_ErrorStop = false;
            Insp2_CV2_ErrorStop = false;
            Insp3_CV1_ErrorStop = false;
            Insp3_CV2_ErrorStop = false;
            Insp4_CV1_ErrorStop = false;
            Insp4_CV2_ErrorStop = false;
        }
    }

    public class WarningHelper
    {
        public bool CodeReader1Fail { get; set; } = false;

        public bool CodeReader2Fail { get; set; } = false;


        public bool FindMarkFail { get; set; } = false;

        public bool FindMarkAcqFail { get; set; } = false;

        public bool CalcHomMatFail { get; set; } = false;

        public bool LoadMapFail { get; set; } = false;

        public bool AutoFocusFail { get; set; } = false;

        public bool WaitAVITimeOut { get; set; } = false;
       
        //当前工单与CST工单不一致
        public bool CurParamSelError { get; set; } = false;

        public bool LightChangeError { get; set; } = false;

        public bool WaitAVICompTimeOut { get; set; } = false;
        public bool WaferIDNotSame { get; set; } = false;
      

        public bool CV1_PresenceError { get; set; } = false;
        public bool CV2_PresenceError { get; set; } = false;
        public bool Insp1_PresenceError { get; set; } = false;
        public bool Insp2_PresenceError { get; set; } = false;
        public bool Insp3_PresenceError { get; set; } = false;
        public bool Insp4_PresenceError { get; set; } = false;
        public bool Insp1_VacError { get; set; } = false;
        public bool Insp2_VacError { get; set; } = false;
        public bool Insp3_VacError { get; set; } = false;
        public bool Insp4_VacError { get; set; } = false;

        public bool CV1_PinUpError { get; set; } = false;
        public bool CV1_PinDownError { get; set; } = false;
        public bool CV2_PinUpError { get; set; } = false;
        public bool CV2_PinDownError { get; set; } = false;
        public bool Insp1_PinUpError { get; set; } = false;
        public bool Insp1_PinDownError { get; set; } = false;
        public bool Insp2_PinUpError { get; set; } = false;
        public bool Insp2_PinDownError { get; set; } = false;
        public bool Insp3_PinUpError { get; set; } = false;
        public bool Insp3_PinDownError { get; set; } = false;
        public bool Insp4_PinUpError { get; set; } = false;
        public bool Insp4_PinDownError { get; set; } = false;

        public bool CV1_Y_AtWaitError { get; set; } = false;
        public bool CV1_Y_AtWorkError { get; set; } = false;
        public bool CV2_Y_AtWaitError { get; set; } = false;
        public bool CV2_Y_AtWorkError { get; set; } = false;
        public bool CV1_TrackSW_Y_AtLDPt1Error { get; set; } = false;
        public bool CV1_TrackSW_Y_AtLDPt2Error { get; set; } = false;
        public bool CV1_TrackSW_Y_AtInsp1Error { get; set; } = false;
        public bool CV1_TrackSW_Y_AtInsp2Error { get; set; } = false;
        public bool CV2_TrackSW_Y_AtLDPt1Error { get; set; } = false;
        public bool CV2_TrackSW_Y_AtLDPt2Error { get; set; } = false;
        public bool CV2_TrackSW_Y_AtInsp1Error { get; set; } = false;
        public bool CV2_TrackSW_Y_AtInsp2Error { get; set; } = false;        

        public bool CCD1_X_AtCH1MarkError { get; set; } = false;
        public bool CCD1_X_AtCH1WorkError { get; set; } = false;
        public bool CCD1_X_AtCH2MarkError { get; set; } = false;
        public bool CCD1_X_AtCH2WorkError { get; set; } = false;
        public bool CCD1_Y_AtCH1MarkError { get; set; } = false;
        public bool CCD1_Y_AtCH1WorkError { get; set; } = false;
        public bool CCD1_Y_AtCH2MarkError { get; set; } = false;
        public bool CCD1_Y_AtCH2WorkError { get; set; } = false;
        public bool CCD1_Z_AtCH1MarkError { get; set; } = false;
        public bool CCD1_Z_AtCH1WorkError { get; set; } = false;
        public bool CCD1_Z_AtCH2MarkError { get; set; } = false;
        public bool CCD1_Z_AtCH2WorkError { get; set; } = false;
        public bool CCD2_X_AtCH1MarkError { get; set; } = false;
        public bool CCD2_X_AtCH1WorkError { get; set; } = false;
        public bool CCD2_X_AtCH2MarkError { get; set; } = false;
        public bool CCD2_X_AtCH2WorkError { get; set; } = false;
        public bool CCD2_Y_AtCH1MarkError { get; set; } = false;
        public bool CCD2_Y_AtCH1WorkError { get; set; } = false;
        public bool CCD2_Y_AtCH2MarkError { get; set; } = false;
        public bool CCD2_Y_AtCH2WorkError { get; set; } = false;
        public bool CCD2_Z_AtCH1MarkError { get; set; } = false;
        public bool CCD2_Z_AtCH1WorkError { get; set; } = false;
        public bool CCD2_Z_AtCH2MarkError { get; set; } = false;
        public bool CCD2_Z_AtCH2WorkError { get; set; } = false;

        public bool Insp1_Y_AtWorkError { get; set; } = false;
        public bool Insp1_Y_AtWaitError { get; set; } = false;       
        public bool Insp2_Y_AtWorkError { get; set; } = false;
        public bool Insp2_Y_AtWaitError { get; set; } = false;        
        public bool Insp3_Y_AtWorkError { get; set; } = false;
        public bool Insp3_Y_AtWaitError { get; set; } = false;       
        public bool Insp4_Y_AtWorkError { get; set; } = false;
        public bool Insp4_Y_AtWaitError { get; set; } = false;
        public bool Insp1_RM_Z_AtWorkError { get; set; } = false;
        public bool Insp1_RM_Z_AtWaitError { get; set; } = false;
        public bool Insp2_RM_Z_AtWorkError { get; set; } = false;
        public bool Insp2_RM_Z_AtWaitError { get; set; } = false;
        public bool Insp3_RM_Z_AtWorkError { get; set; } = false;
        public bool Insp3_RM_Z_AtWaitError { get; set; } = false;
        public bool Insp4_RM_Z_AtWorkError { get; set; } = false;
        public bool Insp4_RM_Z_AtWaitError { get; set; } = false;


        public void WarningReset()
        {            
            Insp1_PresenceError = false;
            Insp2_PresenceError = false;
            Insp3_PresenceError = false;
            Insp4_PresenceError = false;
            Insp1_VacError = false;      
            Insp2_VacError = false;         
            Insp3_VacError = false;
            Insp4_VacError = false;
            CV1_PinUpError = false;
            CV1_PinDownError = false;
            CV2_PinUpError = false;
            CV2_PinDownError = false;
            Insp1_PinUpError = false;
            Insp1_PinDownError = false;
            Insp2_PinUpError = false;
            Insp2_PinDownError = false;
            Insp3_PinUpError = false;
            Insp3_PinDownError = false;
            Insp4_PinUpError = false;
            Insp4_PinDownError = false;

            CV1_Y_AtWaitError = false;
            CV1_Y_AtWorkError = false;
            CV2_Y_AtWaitError = false;
            CV2_Y_AtWorkError = false;
            CV1_TrackSW_Y_AtLDPt1Error = false;
            CV1_TrackSW_Y_AtLDPt2Error = false;
            CV1_TrackSW_Y_AtInsp1Error = false;
            CV1_TrackSW_Y_AtInsp2Error = false;
            CV2_TrackSW_Y_AtLDPt1Error = false;
            CV2_TrackSW_Y_AtLDPt2Error = false;
            CV2_TrackSW_Y_AtInsp1Error = false;
            CV2_TrackSW_Y_AtInsp2Error = false;

            CCD1_X_AtCH1MarkError = false;
            CCD1_X_AtCH1WorkError = false;
            CCD1_X_AtCH2MarkError = false;
            CCD1_X_AtCH2WorkError = false;
            CCD1_Y_AtCH1MarkError = false;
            CCD1_Y_AtCH1WorkError = false;
            CCD1_Y_AtCH2MarkError = false;
            CCD1_Y_AtCH2WorkError = false;
            CCD1_Z_AtCH1MarkError = false;
            CCD1_Z_AtCH1WorkError = false;
            CCD1_Z_AtCH2MarkError = false;
            CCD1_Z_AtCH2WorkError = false;
            CCD2_X_AtCH1MarkError = false;
            CCD2_X_AtCH1WorkError = false;
            CCD2_X_AtCH2MarkError = false;
            CCD2_X_AtCH2WorkError = false;
            CCD2_Y_AtCH1MarkError = false;
            CCD2_Y_AtCH1WorkError = false;
            CCD2_Y_AtCH2MarkError = false;
            CCD2_Y_AtCH2WorkError = false;
            CCD2_Z_AtCH1MarkError = false;
            CCD2_Z_AtCH1WorkError = false;
            CCD2_Z_AtCH2MarkError = false;
            CCD2_Z_AtCH2WorkError = false;

            Insp1_Y_AtWorkError = false;
            Insp1_Y_AtWaitError = false;
            Insp2_Y_AtWorkError = false;
            Insp2_Y_AtWaitError = false;
            Insp3_Y_AtWorkError = false;
            Insp3_Y_AtWaitError = false;
            Insp4_Y_AtWorkError = false;
            Insp4_Y_AtWaitError = false;

            Insp1_RM_Z_AtWorkError = false;
            Insp1_RM_Z_AtWaitError = false;
            Insp2_RM_Z_AtWorkError = false;
            Insp2_RM_Z_AtWaitError = false;
            Insp3_RM_Z_AtWorkError = false;
            Insp3_RM_Z_AtWaitError = false;
            Insp4_RM_Z_AtWorkError = false;
            Insp4_RM_Z_AtWaitError = false;



            CodeReader1Fail = false;
            CodeReader2Fail = false;


            FindMarkFail = false;
            CalcHomMatFail = false;
            LoadMapFail = false;
            AutoFocusFail = false;
            WaitAVITimeOut = false;
           
            CurParamSelError = false;
            LightChangeError = false;
            WaitAVICompTimeOut = false;
            WaferIDNotSame = false;

            //PA.ProcedureHelper_Port.WarningCode = 0;
          
        }
    }
}
